////
////  ASTableView-TPKeyboardAvoiding.swift
////
////  Created by zhuxietong on 2018/8/16.
////
//
//import Foundation
//import AsyncDisplayKit
//import UIKit
//
//// MARK: - UICollectionView
//
//extension ASCollectionView:  UITextFieldDelegate, UITextViewDelegate {
//    override public var contentSize: CGSize {
//        willSet(newValue) {
//            guard !newValue.equalTo(self.contentSize) else { return }
//            
//            super.contentSize = newValue
//            self.TPKeyboardAvoiding_updateContentInset()
//        }
//    }
//    
//    public override var frame: CGRect {
//        didSet {
//            
//            self.TPKeyboardAvoiding_updateContentInset()
//        }
//    }
//    
//
//    
//    public func clearTPAvoid(){
//    
//        NotificationCenter.default.removeObserver(self)
//    }
//    
//    func focusNextTextField() -> Bool {
//        return self.TPKeyboardAvoiding_focusNextTextField()
//    }
//    
//    @objc func scrollToActiveTextField() {
//        return self.TPKeyboardAvoiding_scrollToActiveTextField()
//    }
//    
//    override public func willMove(toSuperview newSuperview: UIView?) {
//        super.willMove(toSuperview: newSuperview)
//        
//        guard newSuperview != nil else { return }
//        NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
//    }
//    
//    override public func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
//        self.TPKeyboardAvoiding_findFirstResponderBeneathView(self)?.resignFirstResponder()
//        super.touchesEnded(touches, with: event)
//    }
//    
//    public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
//        if !self.focusNextTextField() {
//            textField.resignFirstResponder()
//        }
//        return true
//    }
//    
//    override public func layoutSubviews() {
//        super.layoutSubviews()
//        
//        NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
//        
//        Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), userInfo: nil, repeats: false)
//    }
//}
//
//extension ASCollectionView{
//    public func setupTPAvoid() {
//        NotificationCenter.default.addObserver(self, selector: #selector(TPKeyboardAvoiding_keyboardWillShow(_:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
//        
//        NotificationCenter.default.addObserver(self, selector: #selector(TPKeyboardAvoiding_keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
//        
//        NotificationCenter.default.addObserver(self, selector: #selector(scrollToActiveTextField), name: UITextView.textDidBeginEditingNotification, object: nil)
//        
//        NotificationCenter.default.addObserver(self, selector: #selector(scrollToActiveTextField), name: UITextField.textDidBeginEditingNotification, object: nil)
//    }
//}
